<?php
namespace app\common\model;

use think\Model;

class ZiweiLiupanLog extends Model
{
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'createtime_text',
        'sex_text',
        'type_text',
        'leap_bound_text',
        'pros_cons_text',
        'pan_model_text',
        'dx_model_text',
        'sect_text',
        'zhen_text'
    ];
    
    // 性别文字
    public function getSexTextAttr($value, $data)
    {
        $list = [0 => '男', 1 => '女'];
        return isset($list[$data['sex']]) ? $list[$data['sex']] : '';
    }
    
    // 历类型文字
    public function getTypeTextAttr($value, $data)
    {
        $list = [0 => '农历', 1 => '公历'];
        return isset($list[$data['type']]) ? $list[$data['type']] : '';
    }
    
    // 闰月分界文字
    public function getLeapBoundTextAttr($value, $data)
    {
        $list = [0 => '月中分界', 1 => '做下月'];
        return isset($list[$data['leap_bound']]) ? $list[$data['leap_bound']] : '';
    }
    
    // 长生顺逆文字
    public function getProsConsTextAttr($value, $data)
    {
        $list = [
            1 => '全部顺排',
            2 => '按年干阴阳',
            3 => '按照男女'
        ];
        return isset($list[$data['pros_cons']]) ? $list[$data['pros_cons']] : '';
    }
    
    // 盘类型文字
    public function getPanModelTextAttr($value, $data)
    {
        $list = [
            0 => '先天盘+大限盘',
            1 => '流年盘',
            2 => '流月盘',
            3 => '流日盘',
            4 => '流时盘'
        ];
        return isset($list[$data['pan_model']]) ? $list[$data['pan_model']] : '';
    }
    
    // 大限顺逆文字
    public function getDxModelTextAttr($value, $data)
    {
        $list = [
            1 => '阳男阴女顺阴女阳男逆',
            2 => '男顺女逆'
        ];
        return isset($list[$data['dx_model']]) ? $list[$data['dx_model']] : '';
    }
    
    // 流派文字
    public function getSectTextAttr($value, $data)
    {
        $list = [
            1 => '晚子时日柱算明天',
            2 => '晚子时日柱算当天'
        ];
        return isset($list[$data['sect']]) ? $list[$data['sect']] : '';
    }
    
    // 真太阳时文字
    public function getZhenTextAttr($value, $data)
    {
        $list = [1 => '考虑真太阳时', 2 => '不考虑真太阳时'];
        return isset($list[$data['zhen']]) ? $list[$data['zhen']] : '';
    }
    
    // 创建时间文字
    public function getCreatetimeTextAttr($value, $data)
    {
        return date('Y-m-d H:i:s', $data['createtime']);
    }
}